//
//  LLPImageView.m
//  LLP
//
//  Created by Shiyu pan on 12-10-12.
//  Copyright (c) 2012年 Porcellio. All rights reserved.
//

#import "LLPImageView.h"
#import "LLPImageData.h"

@implementation LLPImageView

- (void)dealloc{
    [_refImageData release];
    _refImageData = nil;
    [_animationView release];
    _animationView = nil;
    
    [super dealloc];
}

- (id)initWithImageData:(LLPImageData*)tmpLLPImageData{
    self = [super initWithFrame:CGRectMake(0, 0, 100, 100)];
    if (self) {
        
        _animationView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
        
        [self updateImageData:tmpLLPImageData];
        
    }
    return self;
}

- (void)play{
    [_animationView startAnimating];
}
- (void)stop{
    [_animationView stopAnimating];
}
- (void)updateImageData:(LLPImageData*)newLLPImageData{
    if (!newLLPImageData) {
        return;
    }
    if (_animationView.isAnimating) {
        [_animationView stopAnimating];
    }
    
    self.refImageData = newLLPImageData;
    
    _animationView.animationImages = _refImageData.uiimagesArray;
    _animationView.animationDuration = 2;//设置时间间隔
    _animationView.animationRepeatCount = 0;//loop
}




@end
